﻿Public Class clsGalaxy
    Private m_pCenterStar As ISpaceObject
    Private m_pPlanets As List(Of ISpaceObject)

    Public Sub New(ByVal pCenterPoint As PointF)
        m_pCenterStar = New clsStar(pCenterPoint)

    End Sub
    Public Sub New(ByVal pCenterPoint As PointF, ByVal iAmountOfPlanets As Integer)
        Me.New(pCenterPoint)

        m_pPlanets = New List(Of ISpaceObject)

        Dim r1 As Double
        Dim a As Double

        Dim rnd As New Random(31337)
        Dim pNewPlanet As clsPlanet = Nothing
        Dim pMoon As clsPlanet = Nothing


        For i = 0 To iAmountOfPlanets - 1
            'a = (rnd.NextDouble * Math.PI * 4)
            'If a < Math.PI * 2 Then
            '    r1 = (a / (Math.PI * 2)) * CType(rnd.Next(100, 200), Double) + CType(rnd.Next(3, 30), Double)
            'Else
            '    r1 = ((a - Math.PI) / (Math.PI * 2)) * CType(rnd.Next(100, 200), Double) + CType(rnd.Next(3, 30), Double)
            'End If

            a = (rnd.NextDouble * Math.PI * 2)
            r1 = (rnd.NextDouble * CType(rnd.Next(100, 200), Double)) + CType(rnd.Next(3, 30), Double)

            pNewPlanet = New clsPlanet(rnd.NextDouble * Math.PI * 2, r1, r1 * 1.2, m_pCenterStar)
            m_pPlanets.Add(pNewPlanet)

            If i Mod 50 = 0 Then
                m_pPlanets.Add(New clsPlanet(1.0F, 1.0F, pNewPlanet))
            End If

        Next
    End Sub

    Public Sub Move(ByVal dBaseVelocity As Double)
        For Each pPlanet In m_pPlanets
            CType(pPlanet, clsPlanet).Move(dBaseVelocity)
        Next
    End Sub
    Public Sub Draw(ByRef g As Graphics)
        m_pCenterStar.Draw(g)
        For Each pPlanet In m_pPlanets
            pPlanet.Draw(g)
        Next
    End Sub

    Public Function GetCenterStar() As ISpaceObject
        Return m_pCenterStar
    End Function
    Public Function GetPlanets() As List(Of ISpaceObject)
        Return m_pPlanets
    End Function
End Class
